package com.atguigu.behavior.visitor;

import java.io.File;

public class FileStructure {
    private File path;

    public FileStructure(File path) {
        this.path = path;
    }

    public void handle(Visitor visitor){
        scan(path,visitor);
    }

    public void scan(File file,Visitor visitor){
        if(file.isFile()){
            visitor.visitFile(file);
        }else{
            visitor.visitDir(file);
            for (File sub : file.listFiles()) {
                scan(sub,visitor);
            }
        }
    }
}
